<script>
    import { findMeterTypeOptions } from '@/api/common'
    export default {
        name: 'SearchContion',
        inject: ['tableRoot'],
        data() {
            return {
                meterTypeOptions: [],
                virtuallyOptions: [
                    { code: true, name: '是' },
                    { code: false, name: '否' },
                ],
            }
        },
        created() {
            findMeterTypeOptions().then((res) => {
                const { data = [] } = res
                this.meterTypeOptions = data
                // this.tableRoot.setFields('virtually', false, { refresh: true })
            })
        },
    }
</script>

<template>
    <fragment>
        <GridItem :index="0">
            <SearchFormItem label="名称:">
                <el-input
                    placeholder="请输入"
                    v-model="tableRoot.searchParams.name"
                    size="small"
                    :maxlength="50"
                    clearable
                />
            </SearchFormItem>
        </GridItem>
        <GridItem :index="1">
            <SearchFormItem label="是否虚拟计量器具:">
                <el-select
                    v-model="tableRoot.searchParams.virtually"
                    clearable
                    filterable
                    placeholder="请选择"
                    transfer
                    size="small"
                    style="width: 100%"
                >
                    <el-option
                        v-for="item in virtuallyOptions"
                        :key="item.code"
                        :value="item.code"
                        :label="item.name"
                    />
                </el-select>
            </SearchFormItem>
        </GridItem>
        <GridItem :index="2">
            <SearchFormItem label="编码:">
                <el-input
                    placeholder="请输入"
                    v-model="tableRoot.searchParams.code"
                    size="small"
                    :maxlength="50"
                    clearable
                />
            </SearchFormItem>
        </GridItem>
        <GridItem :index="3">
            <SearchFormItem label="计量器具类型:">
                <el-select
                    v-model="tableRoot.searchParams.typeId"
                    clearable
                    filterable
                    placeholder="请选择类型"
                    transfer
                    size="small"
                    style="width: 100%"
                >
                    <el-option
                        v-for="item in meterTypeOptions"
                        :key="item.code"
                        :value="item.code"
                        :label="item.name"
                    />
                </el-select>
            </SearchFormItem>
        </GridItem>
    </fragment>
</template>
